<?php
session_start();

global $objDbConnection;

if( file_exists( "includes/CommonFunctions.php" ) ) {
	require_once( "includes/CommonFunctions.php" );
	require_once( "includes/MasterDataTypes.php" );
} else {
	require_once( "../includes/CommonFunctions.php" );
	require_once( "../includes/MasterDataTypes.php" );
}

include('header.php');

if(!isset($_SESSION['LOGIN']))
{
	header('location:index.php');
}
// $end=time();
// include("start_timer.php");
// include("end_timer.php");

define('MODULE_FILE', true);

if( isset( $_GET['file'] ) ) {
	
	$arrstrOperationTypes = array( 'insert' => 'insert', 'view' => 'view', 'update' => 'update', 'print' => 'print', 'search' => 'search', 'fetch' => 'fetch', 'download' => 'download', 'forms' => 'forms' );
	
	$modpath = ( ( true == isset( $_GET['type'] ) && true == getArrayElementByKey( $_GET['type'], $arrstrOperationTypes ) ) ? $_GET['type'] . '/' . $_GET['file'] . ".php" : $_GET['file'] . ".php" );
	
	if( true == isset( $_GET['type'] ) && ( 'search' == $_GET['type'] || 'insert' == $_GET['type'] || 'quick_insert' == $_GET['type'] || 'fetch' == $_GET['type'] || 'download' == $_GET['type'] ) || 'forms' == $_GET['type'] ) {
		include( $modpath );
		exit;
	}
	
	if( file_exists( $modpath ) ) {
		include("header_top.php");
?>
	<div id="page-wrapper">
		<div class="row">
		<? include( $modpath ); ?>
		</div>
	</div>
</body>
</html>
<?
		//include("footer.php");
	} else {
		include("header_top.php");
?>
	<div id="page-wrapper">
		<div class="row">
			<?
					echo "<br><center>Sorry, such file doesn't exist...</center><br>";?>
		</div>
	</div>
<?
		//include("footer.php");
	}

}
?>